<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>基于惯性矩与偏心率的描述子 | 荒岛</title><meta name="author" content="Fi9zero"><meta name="copyright" content="Fi9zero"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="基于惯性矩与偏心率的点云描述子pcl::MomentOfInertiaEstimation 是 PCL 提供的一种全局形状描述子，通过分析点云的质量分布来提取其几何特性，适用于物体分类、姿态估计、包围盒生成等任务。  1. 核心功能该程序实现以下功能：  计算点云的 惯性矩（Moment of Inertia） 提取 偏心率（Eccentricity） 生成 AABB（Axis-Aligned B">
<meta property="og:type" content="article">
<meta property="og:title" content="基于惯性矩与偏心率的描述子">
<meta property="og:url" content="https://ckyfi9zero.github.io/2025/08/03/2025-08-03-%E5%9F%BA%E4%BA%8E%E6%83%AF%E6%80%A7%E7%9F%A9%E4%B8%8E%E5%81%8F%E5%BF%83%E7%8E%87%E7%9A%84%E6%8F%8F%E8%BF%B0%E5%AD%90/index.html">
<meta property="og:site_name" content="荒岛">
<meta property="og:description" content="基于惯性矩与偏心率的点云描述子pcl::MomentOfInertiaEstimation 是 PCL 提供的一种全局形状描述子，通过分析点云的质量分布来提取其几何特性，适用于物体分类、姿态估计、包围盒生成等任务。  1. 核心功能该程序实现以下功能：  计算点云的 惯性矩（Moment of Inertia） 提取 偏心率（Eccentricity） 生成 AABB（Axis-Aligned B">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://ckyfi9zero.github.io/image/avatar.jpg">
<meta property="article:published_time" content="2025-08-03T11:36:31.000Z">
<meta property="article:modified_time" content="2025-08-03T11:51:08.735Z">
<meta property="article:author" content="Fi9zero">
<meta property="article:tag" content="c++">
<meta property="article:tag" content="PCL">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://ckyfi9zero.github.io/image/avatar.jpg"><script type="application/ld+json">{
  "@context": "https://schema.org",
  "@type": "BlogPosting",
  "headline": "基于惯性矩与偏心率的描述子",
  "url": "https://ckyfi9zero.github.io/2025/08/03/2025-08-03-%E5%9F%BA%E4%BA%8E%E6%83%AF%E6%80%A7%E7%9F%A9%E4%B8%8E%E5%81%8F%E5%BF%83%E7%8E%87%E7%9A%84%E6%8F%8F%E8%BF%B0%E5%AD%90/",
  "image": "https://ckyfi9zero.github.io/image/avatar.jpg",
  "datePublished": "2025-08-03T11:36:31.000Z",
  "dateModified": "2025-08-03T11:51:08.735Z",
  "author": [
    {
      "@type": "Person",
      "name": "Fi9zero",
      "url": "https://ckyfi9zero.github.io"
    }
  ]
}</script><link rel="shortcut icon" href="/image/favicon.ico"><link rel="canonical" href="https://ckyfi9zero.github.io/2025/08/03/2025-08-03-%E5%9F%BA%E4%BA%8E%E6%83%AF%E6%80%A7%E7%9F%A9%E4%B8%8E%E5%81%8F%E5%BF%83%E7%8E%87%E7%9A%84%E6%8F%8F%E8%BF%B0%E5%AD%90/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css"><script>
    (() => {
      
    const saveToLocal = {
      set: (key, value, ttl) => {
        if (!ttl) return
        const expiry = Date.now() + ttl * 86400000
        localStorage.setItem(key, JSON.stringify({ value, expiry }))
      },
      get: key => {
        const itemStr = localStorage.getItem(key)
        if (!itemStr) return undefined
        const { value, expiry } = JSON.parse(itemStr)
        if (Date.now() > expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return value
      }
    }

    window.btf = {
      saveToLocal,
      getScript: (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        Object.entries(attr).forEach(([key, val]) => script.setAttribute(key, val))
        script.onload = script.onreadystatechange = () => {
          if (!script.readyState || /loaded|complete/.test(script.readyState)) resolve()
        }
        script.onerror = reject
        document.head.appendChild(script)
      }),
      getCSS: (url, id) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onload = link.onreadystatechange = () => {
          if (!link.readyState || /loaded|complete/.test(link.readyState)) resolve()
        }
        link.onerror = reject
        document.head.appendChild(link)
      }),
      addGlobalFn: (key, fn, name = false, parent = window) => {
        if (!false && key.startsWith('pjax')) return
        const globalFn = parent.globalFn || {}
        globalFn[key] = globalFn[key] || {}
        globalFn[key][name || Object.keys(globalFn[key]).length] = fn
        parent.globalFn = globalFn
      }
    }
  
      
      const activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      const activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }

      btf.activateDarkMode = activateDarkMode
      btf.activateLightMode = activateLightMode

      const theme = saveToLocal.get('theme')
    
          theme === 'dark' ? activateDarkMode() : theme === 'light' ? activateLightMode() : null
        
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        document.documentElement.classList.toggle('hide-aside', asideStatus === 'hide')
      }
    
      
    const detectApple = () => {
      if (/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)) {
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
  
    })()
  </script><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":true,"top_n_per_article":1,"unescape":false,"languages":{"hits_empty":"未找到符合您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false,"highlightFullpage":false,"highlightMacStyle":true},
  copy: {
    success: '复制成功',
    error: '复制失败',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'null',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid/dist/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyloadPlugin: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '基于惯性矩与偏心率的描述子',
  isHighlightShrink: false,
  isToc: true,
  pageType: 'post'
}</script><link rel="stylesheet" href="/css/custom.css"><link rel="stylesheet" href="/css/pig.css"><link rel="stylesheet" href="https://npm.elemecdn.com/ethan4116-blog/lib/css/plane_v2.css"><meta name="generator" content="Hexo 7.3.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img text-center"><img src="/image/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data text-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">54</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">15</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/booklist/"><i class="fa-fw fas fa-book"></i><span> 书单</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url(/image/per%20page.jpg);"><nav id="nav"><span id="blog-info"><a class="nav-site-title" href="/"><span class="site-name">荒岛</span></a><a class="nav-page-title" href="/"><span class="site-name">基于惯性矩与偏心率的描述子</span><span class="site-name"><i class="fa-solid fa-circle-arrow-left"></i><span>  返回首页</span></span></a></span><div id="menus"><div id="search-button"><span class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></span></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/booklist/"><i class="fa-fw fas fa-book"></i><span> 书单</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><span class="site-page"><i class="fas fa-bars fa-fw"></i></span></div></div></nav><div id="post-info"><h1 class="post-title">基于惯性矩与偏心率的描述子</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2025-08-03T11:36:31.000Z" title="发表于 2025-08-03 19:36:31">2025-08-03</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2025-08-03T11:51:08.735Z" title="更新于 2025-08-03 19:51:08">2025-08-03</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/PCL/">PCL</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title=""><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">浏览量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="container post-content" id="article-container"><h1 id="基于惯性矩与偏心率的点云描述子"><a href="#基于惯性矩与偏心率的点云描述子" class="headerlink" title="基于惯性矩与偏心率的点云描述子"></a>基于惯性矩与偏心率的点云描述子</h1><p><code>pcl::MomentOfInertiaEstimation</code> 是 PCL 提供的一种全局形状描述子，通过分析点云的<strong>质量分布</strong>来提取其几何特性，适用于物体分类、姿态估计、包围盒生成等任务。</p>
<hr>
<h2 id="1-核心功能"><a href="#1-核心功能" class="headerlink" title="1. 核心功能"></a>1. 核心功能</h2><p>该程序实现以下功能：</p>
<ul>
<li>计算点云的 <strong>惯性矩（Moment of Inertia）</strong></li>
<li>提取 <strong>偏心率（Eccentricity）</strong></li>
<li>生成 <strong>AABB（Axis-Aligned Bounding Box）</strong></li>
<li>生成 <strong>OBB（Oriented Bounding Box）</strong></li>
<li>提取 <strong>主方向（主成分方向）</strong></li>
<li>可视化所有几何信息</li>
</ul>
<hr>
<h2 id="2-关键输出信息"><a href="#2-关键输出信息" class="headerlink" title="2. 关键输出信息"></a>2. 关键输出信息</h2><table>
<thead>
<tr>
<th>方法</th>
<th>输出内容</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td><code>getMomentOfInertia()</code></td>
<td><code>vector&lt;float&gt;</code>（3个值）</td>
<td>描述点云绕三个主轴的旋转惯性</td>
</tr>
<tr>
<td><code>getEccentricity()</code></td>
<td><code>vector&lt;float&gt;</code>（3个值）</td>
<td>表示形状的“拉伸程度”，接近1表示细长</td>
</tr>
<tr>
<td><code>getAABB()</code></td>
<td>最小&#x2F;最大点</td>
<td>轴对齐包围盒，不考虑方向</td>
</tr>
<tr>
<td><code>getOBB()</code></td>
<td>中心、旋转、尺寸</td>
<td>最小体积包围盒，反映物体真实朝向</td>
</tr>
<tr>
<td><code>getEigenValues()</code></td>
<td>major, middle, minor</td>
<td>主成分分析（PCA）的特征值</td>
</tr>
<tr>
<td><code>getEigenVectors()</code></td>
<td>三个方向向量</td>
<td>主方向（最长轴）、次方向、最短轴</td>
</tr>
<tr>
<td><code>getMassCenter()</code></td>
<td>质心坐标</td>
<td>点云的几何中心</td>
</tr>
</tbody></table>
<hr>
<h2 id="3-可视化内容"><a href="#3-可视化内容" class="headerlink" title="3. 可视化内容"></a>3. 可视化内容</h2><table>
<thead>
<tr>
<th>元素</th>
<th>颜色</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>点云</td>
<td>绿色</td>
<td>原始输入点云</td>
</tr>
<tr>
<td>AABB</td>
<td>红色</td>
<td>轴对齐包围盒（不旋转）</td>
</tr>
<tr>
<td>OBB</td>
<td>蓝色</td>
<td>有方向包围盒（贴合物体）</td>
</tr>
<tr>
<td>主方向线</td>
<td>红&#x2F;绿&#x2F;蓝</td>
<td>分别表示最大、中间、最小主方向</td>
</tr>
</tbody></table>
<blockquote>
<p>🔍 <strong>OBB 的构建方式</strong>：</p>
<ul>
<li>中心：<code>position_OBB</code></li>
<li>旋转：<code>rotational_matrix_OBB</code> → 转为 <code>Eigen::Quaternionf</code></li>
<li>尺寸：<code>max_point_OBB - min_point_OBB</code></li>
</ul>
</blockquote>
<hr>
<h2 id="4-物理与几何意义"><a href="#4-物理与几何意义" class="headerlink" title="4. 物理与几何意义"></a>4. 物理与几何意义</h2><h3 id="✅-惯性矩（Moment-of-Inertia）"><a href="#✅-惯性矩（Moment-of-Inertia）" class="headerlink" title="✅ 惯性矩（Moment of Inertia）"></a>✅ 惯性矩（Moment of Inertia）</h3><ul>
<li>反映点云在空间中的“质量”分布惯性</li>
<li>值越大，表示该方向上点分布越分散</li>
<li>用于区分球体、细长杆、平板等形状</li>
</ul>
<h3 id="✅-偏心率（Eccentricity）"><a href="#✅-偏心率（Eccentricity）" class="headerlink" title="✅ 偏心率（Eccentricity）"></a>✅ 偏心率（Eccentricity）</h3><ul>
<li>定义：$$e &#x3D; \sqrt{1 - \frac{λ_{min}}{λ_{max}}^2}$$</li>
<li>值接近 1：细长物体（如柱体）</li>
<li>值接近 0：接近球体</li>
<li>可用于粗略分类</li>
</ul>
<h3 id="✅-OBB-vs-AABB"><a href="#✅-OBB-vs-AABB" class="headerlink" title="✅ OBB vs AABB"></a>✅ OBB vs AABB</h3><table>
<thead>
<tr>
<th>类型</th>
<th>是否旋转</th>
<th>体积</th>
<th>用途</th>
</tr>
</thead>
<tbody><tr>
<td>AABB</td>
<td>否</td>
<td>较大</td>
<td>快速碰撞检测</td>
</tr>
<tr>
<td>OBB</td>
<td>是</td>
<td>最小</td>
<td>精确包围、姿态估计</td>
</tr>
</tbody></table>
<hr>
<h2 id="5-应用场景"><a href="#5-应用场景" class="headerlink" title="5. 应用场景"></a>5. 应用场景</h2><ul>
<li><strong>物体分类</strong>：通过惯性矩和偏心率判断物体类型（球、柱、板）</li>
<li><strong>机器人抓取</strong>：OBB 提供物体主方向，指导机械臂抓取姿态</li>
<li><strong>点云配准预处理</strong>：用主方向初始化旋转对齐</li>
<li><strong>场景理解</strong>：识别结构化物体（如桌椅、箱子）</li>
</ul>
<hr>
<h2 id="6-注意事项"><a href="#6-注意事项" class="headerlink" title="6. 注意事项"></a>6. 注意事项</h2><ul>
<li><code>argc != 2</code> 时静默退出，建议改为打印用法提示</li>
<li><code>addCube</code> 已自动绘制 OBB，无需手动添加 12 条边</li>
<li><code>spinOnce()</code> 循环中建议使用 <code>usleep(10000)</code> 或 <code>std::this_thread::sleep_for()</code>（C++11）</li>
<li>点云应去噪、去地面，避免质心偏移</li>
</ul>
<hr>
<h2 id="代码实现"><a href="#代码实现" class="headerlink" title="代码实现"></a>代码实现</h2><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 包含 PCL 惯性矩估计头文件</span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/features/moment_of_inertia_estimation.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">// 标准库：使用 vector 存储数据</span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;vector&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">// PCL 点云输入输出（PCD 文件读写）</span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/io/pcd_io.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">// 定义点类型（PointXYZ）</span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/point_types.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">// 可视化工具：PCLVisualizer</span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/visualization/cloud_viewer.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">// 多线程支持（用于可视化循环）</span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;boost/thread/thread.hpp&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">// 使用标准命名空间</span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">(<span class="type">int</span> argc, <span class="type">char</span>** argv)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  <span class="comment">// 检查命令行参数：必须传入一个 .pcd 文件路径</span></span><br><span class="line">  <span class="keyword">if</span> (argc != <span class="number">2</span>)</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;  <span class="comment">// 参数错误则退出（静默退出，建议改为报错提示）</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">// 创建智能指针，存储 XYZ 类型的点云</span></span><br><span class="line">  pcl::PointCloud&lt;pcl::PointXYZ&gt;::<span class="function">Ptr <span class="title">cloud</span><span class="params">(<span class="keyword">new</span> pcl::PointCloud&lt;pcl::PointXYZ&gt;())</span></span>;</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 加载 PCD 文件到 cloud，失败返回 -1</span></span><br><span class="line">  <span class="keyword">if</span> (pcl::io::<span class="built_in">loadPCDFile</span>(argv[<span class="number">1</span>], *cloud) == <span class="number">-1</span>)</span><br><span class="line">    <span class="keyword">return</span> <span class="number">-1</span>;</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 创建惯性矩特征提取器</span></span><br><span class="line">  pcl::MomentOfInertiaEstimation&lt;pcl::PointXYZ&gt; feature_extractor;</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 设置输入点云</span></span><br><span class="line">  feature_extractor.<span class="built_in">setInputCloud</span>(cloud);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 执行计算（核心步骤：计算惯性矩、OBB、AABB、主方向等）</span></span><br><span class="line">  feature_extractor.<span class="built_in">compute</span>();</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 存储输出结果的变量</span></span><br><span class="line">  std::vector&lt;<span class="type">float</span>&gt; moment_of_inertia;     <span class="comment">// 惯性矩（三个主轴方向）</span></span><br><span class="line">  std::vector&lt;<span class="type">float</span>&gt; eccentricity;          <span class="comment">// 偏心率（描述形状拉伸程度）</span></span><br><span class="line">  pcl::PointXYZ min_point_AABB, max_point_AABB;  <span class="comment">// 轴对齐包围盒（AABB）的最小最大点</span></span><br><span class="line">  pcl::PointXYZ min_point_OBB, max_point_OBB;    <span class="comment">// 方向包围盒（OBB）的局部最小最大点</span></span><br><span class="line">  pcl::PointXYZ position_OBB;                    <span class="comment">// OBB 的中心位置</span></span><br><span class="line">  Eigen::Matrix3f rotational_matrix_OBB;         <span class="comment">// OBB 的旋转矩阵（描述朝向）</span></span><br><span class="line">  <span class="type">float</span> major_value, middle_value, minor_value;  <span class="comment">// 主特征值（从大到小）</span></span><br><span class="line">  Eigen::Vector3f major_vector, middle_vector, minor_vector;  <span class="comment">// 主特征向量（方向）</span></span><br><span class="line">  Eigen::Vector3f mass_center;                   <span class="comment">// 质心（质量中心）</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">// 获取计算结果</span></span><br><span class="line">  feature_extractor.<span class="built_in">getMomentOfInertia</span>(moment_of_inertia);     <span class="comment">// 获取三个惯性矩</span></span><br><span class="line">  feature_extractor.<span class="built_in">getEccentricity</span>(eccentricity);             <span class="comment">// 获取偏心率</span></span><br><span class="line">  feature_extractor.<span class="built_in">getAABB</span>(min_point_AABB, max_point_AABB);   <span class="comment">// 获取 AABB</span></span><br><span class="line">  feature_extractor.<span class="built_in">getOBB</span>(min_point_OBB, max_point_OBB, position_OBB, rotational_matrix_OBB); <span class="comment">// 获取 OBB</span></span><br><span class="line">  feature_extractor.<span class="built_in">getEigenValues</span>(major_value, middle_value, minor_value); <span class="comment">// 获取特征值</span></span><br><span class="line">  feature_extractor.<span class="built_in">getEigenVectors</span>(major_vector, middle_vector, minor_vector); <span class="comment">// 获取特征向量</span></span><br><span class="line">  feature_extractor.<span class="built_in">getMassCenter</span>(mass_center); <span class="comment">// 获取质心</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">// 创建可视化窗口</span></span><br><span class="line">  <span class="function">boost::shared_ptr&lt;pcl::visualization::PCLVisualizer&gt; <span class="title">viewer</span><span class="params">(</span></span></span><br><span class="line"><span class="params"><span class="function">      <span class="keyword">new</span> pcl::visualization::PCLVisualizer(<span class="string">&quot;点云库PCL学习教程第二版-基于惯性矩与偏心率的描述子&quot;</span>))</span></span>;</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 设置背景颜色为白色 (R=1, G=1, B=1)</span></span><br><span class="line">  viewer-&gt;<span class="built_in">setBackgroundColor</span>(<span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 添加坐标系，长度为 1.0</span></span><br><span class="line">  viewer-&gt;<span class="built_in">addCoordinateSystem</span>(<span class="number">1.0</span>);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 初始化相机参数</span></span><br><span class="line">  viewer-&gt;<span class="built_in">initCameraParameters</span>();</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 添加点云，绿色显示</span></span><br><span class="line">  viewer-&gt;<span class="built_in">addPointCloud</span>&lt;pcl::PointXYZ&gt;(</span><br><span class="line">      cloud,</span><br><span class="line">      pcl::visualization::<span class="built_in">PointCloudColorHandlerCustom</span>&lt;pcl::PointXYZ&gt;(cloud, <span class="number">0</span>, <span class="number">255</span>, <span class="number">0</span>),</span><br><span class="line">      <span class="string">&quot;sample cloud&quot;</span>);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 设置点的大小为 5</span></span><br><span class="line">  viewer-&gt;<span class="built_in">setPointCloudRenderingProperties</span>(</span><br><span class="line">      pcl::visualization::PCL_VISUALIZER_POINT_SIZE, <span class="number">5</span>, <span class="string">&quot;sample cloud&quot;</span>);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 添加 AABB（轴对齐包围盒），红色</span></span><br><span class="line">  viewer-&gt;<span class="built_in">addCube</span>(</span><br><span class="line">      min_point_AABB.x, max_point_AABB.x,</span><br><span class="line">      min_point_AABB.y, max_point_AABB.y,</span><br><span class="line">      min_point_AABB.z, max_point_AABB.z,</span><br><span class="line">      <span class="number">1.0</span>, <span class="number">0.0</span>, <span class="number">0.0</span>,  <span class="comment">// 颜色：红色</span></span><br><span class="line">      <span class="string">&quot;AABB&quot;</span>);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 设置 AABB 的透明度为 0.1（半透明）</span></span><br><span class="line">  viewer-&gt;<span class="built_in">setShapeRenderingProperties</span>(</span><br><span class="line">      pcl::visualization::PCL_VISUALIZER_OPACITY, <span class="number">0.1</span>, <span class="string">&quot;AABB&quot;</span>);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 设置 AABB 的线宽为 4</span></span><br><span class="line">  viewer-&gt;<span class="built_in">setShapeRenderingProperties</span>(</span><br><span class="line">      pcl::visualization::PCL_VISUALIZER_LINE_WIDTH, <span class="number">4</span>, <span class="string">&quot;AABB&quot;</span>);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 将 OBB 中心转为 Eigen::Vector3f 类型</span></span><br><span class="line">  <span class="function">Eigen::Vector3f <span class="title">position</span><span class="params">(position_OBB.x, position_OBB.y, position_OBB.z)</span></span>;</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 打印调试信息</span></span><br><span class="line">  std::cout &lt;&lt; <span class="string">&quot;position_OBB: &quot;</span> &lt;&lt; position_OBB &lt;&lt; std::endl;</span><br><span class="line">  std::cout &lt;&lt; <span class="string">&quot;mass_center: &quot;</span> &lt;&lt; mass_center &lt;&lt; std::endl;</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 从旋转矩阵构造四元数（用于 addCube）</span></span><br><span class="line">  <span class="function">Eigen::Quaternionf <span class="title">quat</span><span class="params">(rotational_matrix_OBB)</span></span>;</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 添加 OBB（有方向的包围盒），蓝色</span></span><br><span class="line">  viewer-&gt;<span class="built_in">addCube</span>(</span><br><span class="line">      position, quat,                           <span class="comment">// 中心 + 旋转</span></span><br><span class="line">      max_point_OBB.x - min_point_OBB.x,       <span class="comment">// 长度（x方向）</span></span><br><span class="line">      max_point_OBB.y - min_point_OBB.y,       <span class="comment">// 宽度（y方向）</span></span><br><span class="line">      max_point_OBB.z - min_point_OBB.z,       <span class="comment">// 高度（z方向）</span></span><br><span class="line">      <span class="string">&quot;OBB&quot;</span>);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 设置 OBB 颜色为蓝色</span></span><br><span class="line">  viewer-&gt;<span class="built_in">setShapeRenderingProperties</span>(</span><br><span class="line">      pcl::visualization::PCL_VISUALIZER_COLOR, <span class="number">0</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="string">&quot;OBB&quot;</span>);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 设置 OBB 透明度</span></span><br><span class="line">  viewer-&gt;<span class="built_in">setShapeRenderingProperties</span>(</span><br><span class="line">      pcl::visualization::PCL_VISUALIZER_OPACITY, <span class="number">0.1</span>, <span class="string">&quot;OBB&quot;</span>);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 设置 OBB 线宽</span></span><br><span class="line">  viewer-&gt;<span class="built_in">setShapeRenderingProperties</span>(</span><br><span class="line">      pcl::visualization::PCL_VISUALIZER_LINE_WIDTH, <span class="number">4</span>, <span class="string">&quot;OBB&quot;</span>);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 将所有几何体设为线框模式（Wireframe）</span></span><br><span class="line">  viewer-&gt;<span class="built_in">setRepresentationToWireframeForAllActors</span>();</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 构造主方向向量的端点（从质心出发）</span></span><br><span class="line">  <span class="function">pcl::PointXYZ <span class="title">center</span><span class="params">(mass_center(<span class="number">0</span>), mass_center(<span class="number">1</span>), mass_center(<span class="number">2</span>))</span></span>;</span><br><span class="line">  <span class="function">pcl::PointXYZ <span class="title">x_axis</span><span class="params">(</span></span></span><br><span class="line"><span class="params"><span class="function">      major_vector(<span class="number">0</span>) + mass_center(<span class="number">0</span>),</span></span></span><br><span class="line"><span class="params"><span class="function">      major_vector(<span class="number">1</span>) + mass_center(<span class="number">1</span>),</span></span></span><br><span class="line"><span class="params"><span class="function">      major_vector(<span class="number">2</span>) + mass_center(<span class="number">2</span>))</span></span>;  <span class="comment">// 主方向（红色）</span></span><br><span class="line"></span><br><span class="line">  <span class="function">pcl::PointXYZ <span class="title">y_axis</span><span class="params">(</span></span></span><br><span class="line"><span class="params"><span class="function">      middle_vector(<span class="number">0</span>) + mass_center(<span class="number">0</span>),</span></span></span><br><span class="line"><span class="params"><span class="function">      middle_vector(<span class="number">1</span>) + mass_center(<span class="number">1</span>),</span></span></span><br><span class="line"><span class="params"><span class="function">      middle_vector(<span class="number">2</span>) + mass_center(<span class="number">2</span>))</span></span>;  <span class="comment">// 次方向（绿色）</span></span><br><span class="line"></span><br><span class="line">  <span class="function">pcl::PointXYZ <span class="title">z_axis</span><span class="params">(</span></span></span><br><span class="line"><span class="params"><span class="function">      minor_vector(<span class="number">0</span>) + mass_center(<span class="number">0</span>),</span></span></span><br><span class="line"><span class="params"><span class="function">      minor_vector(<span class="number">1</span>) + mass_center(<span class="number">1</span>),</span></span></span><br><span class="line"><span class="params"><span class="function">      minor_vector(<span class="number">2</span>) + mass_center(<span class="number">2</span>))</span></span>;  <span class="comment">// 最小方向（蓝色）</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">// 在可视化窗口中绘制三个主方向的线段</span></span><br><span class="line">  viewer-&gt;<span class="built_in">addLine</span>(center, x_axis, <span class="number">1.0f</span>, <span class="number">0.0f</span>, <span class="number">0.0f</span>, <span class="string">&quot;major eigen vector&quot;</span>);   <span class="comment">// 红色</span></span><br><span class="line">  viewer-&gt;<span class="built_in">addLine</span>(center, y_axis, <span class="number">0.0f</span>, <span class="number">1.0f</span>, <span class="number">0.0f</span>, <span class="string">&quot;middle eigen vector&quot;</span>);  <span class="comment">// 绿色</span></span><br><span class="line">  viewer-&gt;<span class="built_in">addLine</span>(center, z_axis, <span class="number">0.0f</span>, <span class="number">0.0f</span>, <span class="number">1.0f</span>, <span class="string">&quot;minor eigen vector&quot;</span>);   <span class="comment">// 蓝色</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">// 输出调试信息</span></span><br><span class="line">  std::cout &lt;&lt; <span class="string">&quot;size of cloud: &quot;</span> &lt;&lt; cloud-&gt;points.<span class="built_in">size</span>() &lt;&lt; std::endl;</span><br><span class="line">  std::cout &lt;&lt; <span class="string">&quot;moment_of_inertia size: &quot;</span> &lt;&lt; moment_of_inertia.<span class="built_in">size</span>() &lt;&lt; std::endl;</span><br><span class="line">  std::cout &lt;&lt; <span class="string">&quot;eccentricity size: &quot;</span> &lt;&lt; eccentricity.<span class="built_in">size</span>() &lt;&lt; std::endl;</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 被注释的代码：手动绘制 OBB 的 12 条边（addCube 已自动完成，无需重复）</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">// 主循环：持续刷新可视化窗口，直到关闭</span></span><br><span class="line">  <span class="keyword">while</span> (!viewer-&gt;<span class="built_in">wasStopped</span>())</span><br><span class="line">  &#123;</span><br><span class="line">    viewer-&gt;<span class="built_in">spinOnce</span>(<span class="number">100</span>);  <span class="comment">// 每次刷新 100ms</span></span><br><span class="line">    boost::this_thread::<span class="built_in">sleep</span>(boost::posix_time::<span class="built_in">microseconds</span>(<span class="number">100000</span>));  <span class="comment">// 延迟 0.1 秒</span></span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">position_OBB: (-10.135,0.102328,-2.43558)</span><br><span class="line">mass_center:  -10.1042</span><br><span class="line">0.0740048</span><br><span class="line"> -2.14475</span><br><span class="line">size of cloud :1771</span><br><span class="line">moment_of_inertia :370</span><br><span class="line">eccentricity :370</span><br></pre></td></tr></table></figure>
<p><img src="https://ckyfi9zero.github.io/picx-images-hosting/20250803/image.491l5g34wq.webp" alt="image"></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://ckyfi9zero.github.io">Fi9zero</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://ckyfi9zero.github.io/2025/08/03/2025-08-03-%E5%9F%BA%E4%BA%8E%E6%83%AF%E6%80%A7%E7%9F%A9%E4%B8%8E%E5%81%8F%E5%BF%83%E7%8E%87%E7%9A%84%E6%8F%8F%E8%BF%B0%E5%AD%90/">https://ckyfi9zero.github.io/2025/08/03/2025-08-03-%E5%9F%BA%E4%BA%8E%E6%83%AF%E6%80%A7%E7%9F%A9%E4%B8%8E%E5%81%8F%E5%BF%83%E7%8E%87%E7%9A%84%E6%8F%8F%E8%BF%B0%E5%AD%90/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来源 <a href="https://ckyfi9zero.github.io" target="_blank">荒岛</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/c/">c++</a><a class="post-meta__tags" href="/tags/PCL/">PCL</a></div><div class="post-share"><div class="social-share" data-image="/image/avatar.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><a class="pagination-related  no-desc" href="/2025/08/03/2025-08-03-%E6%B1%82%E7%82%B9%E4%BA%91%E6%95%B0%E6%8D%AE%E7%9A%84%E8%BE%B9%E7%95%8C%E7%82%B9%E4%BA%91/" title="求点云数据的边界点云"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info"><div class="info-1"><div class="info-item-1">上一篇</div><div class="info-item-2">求点云数据的边界点云</div></div></div></a><a class="pagination-related  no-desc" href="/2025/08/03/2025-08-03-RoPS/" title="RoPS"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-right"><div class="info-1"><div class="info-item-1">下一篇</div><div class="info-item-2">RoPS</div></div></div></a></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><a class="pagination-related no-desc" href="/2025/07/31/2025-07-31-%E7%94%A8kdtree%E5%AE%9E%E7%8E%B0%E5%BF%AB%E9%80%9F%E9%A2%86%E5%9F%9F%E6%90%9C%E7%B4%A2/" title="用kdtree实现快速领域搜索"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-07-31</div><div class="info-item-2">用kdtree实现快速领域搜索</div></div></div></a><a class="pagination-related no-desc" href="/2025/07/31/2025-07-31-%E7%94%A8%E5%85%AB%E5%8F%89%E6%A0%91%E8%BF%9B%E8%A1%8C%E6%97%A0%E5%BA%8F%E7%82%B9%E4%BA%91%E6%95%B0%E6%8D%AE%E7%9A%84%E7%A9%BA%E9%97%B4%E5%8F%98%E5%8C%96%E6%A3%80%E6%B5%8B/" title="用八叉树进行无序点云数据的空间变化检测"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-07-31</div><div class="info-item-2">用八叉树进行无序点云数据的空间变化检测</div></div></div></a><a class="pagination-related no-desc" href="/2025/07/31/2025-07-31-%E7%94%A8%E7%9B%B4%E9%80%9A%E6%BB%A4%E6%B3%A2%E5%99%A8%E5%AF%B9%E7%82%B9%E4%BA%91%E8%BF%9B%E8%A1%8C%E6%BB%A4%E6%B3%A2%E5%A4%84%E7%90%86/" title="用直通滤波器对点云进行滤波处理"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-07-31</div><div class="info-item-2">用直通滤波器对点云进行滤波处理</div></div></div></a><a class="pagination-related no-desc" href="/2025/08/01/2025-08-01-%E4%BB%8E%E7%82%B9%E4%BA%91%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E6%B7%B1%E5%BA%A6%E5%9B%BE%E5%83%8F/" title="从点云创建一个深度图像"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-08-01</div><div class="info-item-2">从点云创建一个深度图像</div></div></div></a><a class="pagination-related no-desc" href="/2025/08/01/2025-08-01-%E4%BB%8E%E4%B8%80%E4%B8%AA%E7%82%B9%E4%BA%91%E4%B8%AD%E6%8F%90%E5%8F%96%E4%B8%80%E4%B8%AA%E5%AD%90%E9%9B%86/" title="从一个点云中提取一个子集"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-08-01</div><div class="info-item-2">从一个点云中提取一个子集</div></div></div></a><a class="pagination-related no-desc" href="/2025/08/01/2025-08-01-%E5%9C%A8%E6%BB%A4%E6%B3%A2%E5%99%A8%E6%A8%A1%E5%9D%97%E7%A7%BB%E9%99%A4%E7%A6%BB%E7%BE%A4%E7%82%B9/" title="在滤波器模块移除离群点"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-08-01</div><div class="info-item-2">在滤波器模块移除离群点</div></div></div></a></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info text-center"><div class="avatar-img"><img src="/image/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info-name">Fi9zero</div><div class="author-info-description"></div><div class="site-data"><a href="/archives/"><div class="headline">文章</div><div class="length-num">54</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">15</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/ckyFi9zero"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons"><a class="social-icon" href="https://github.com/ckyFi9zero" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:2539894206@qq.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%9F%BA%E4%BA%8E%E6%83%AF%E6%80%A7%E7%9F%A9%E4%B8%8E%E5%81%8F%E5%BF%83%E7%8E%87%E7%9A%84%E7%82%B9%E4%BA%91%E6%8F%8F%E8%BF%B0%E5%AD%90"><span class="toc-number">1.</span> <span class="toc-text">基于惯性矩与偏心率的点云描述子</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-%E6%A0%B8%E5%BF%83%E5%8A%9F%E8%83%BD"><span class="toc-number">1.1.</span> <span class="toc-text">1. 核心功能</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-%E5%85%B3%E9%94%AE%E8%BE%93%E5%87%BA%E4%BF%A1%E6%81%AF"><span class="toc-number">1.2.</span> <span class="toc-text">2. 关键输出信息</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-%E5%8F%AF%E8%A7%86%E5%8C%96%E5%86%85%E5%AE%B9"><span class="toc-number">1.3.</span> <span class="toc-text">3. 可视化内容</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-%E7%89%A9%E7%90%86%E4%B8%8E%E5%87%A0%E4%BD%95%E6%84%8F%E4%B9%89"><span class="toc-number">1.4.</span> <span class="toc-text">4. 物理与几何意义</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%9C%85-%E6%83%AF%E6%80%A7%E7%9F%A9%EF%BC%88Moment-of-Inertia%EF%BC%89"><span class="toc-number">1.4.1.</span> <span class="toc-text">✅ 惯性矩（Moment of Inertia）</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%9C%85-%E5%81%8F%E5%BF%83%E7%8E%87%EF%BC%88Eccentricity%EF%BC%89"><span class="toc-number">1.4.2.</span> <span class="toc-text">✅ 偏心率（Eccentricity）</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%9C%85-OBB-vs-AABB"><span class="toc-number">1.4.3.</span> <span class="toc-text">✅ OBB vs AABB</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5-%E5%BA%94%E7%94%A8%E5%9C%BA%E6%99%AF"><span class="toc-number">1.5.</span> <span class="toc-text">5. 应用场景</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#6-%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9"><span class="toc-number">1.6.</span> <span class="toc-text">6. 注意事项</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0"><span class="toc-number">1.7.</span> <span class="toc-text">代码实现</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/10/05/2025-10-05-lio_sam/" title="lio_sam">lio_sam</a><time datetime="2025-10-05T02:43:51.000Z" title="发表于 2025-10-05 10:43:51">2025-10-05</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/12/2025-08-12-%E4%BD%BF%E7%94%A8docker%E6%90%AD%E5%BB%BApytorch%E7%8E%AF%E5%A2%83/" title="使用docker搭建pytorch环境">使用docker搭建pytorch环境</a><time datetime="2025-08-12T12:43:33.000Z" title="发表于 2025-08-12 20:43:33">2025-08-12</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/05/2025-08-05-docker/" title="docker">docker</a><time datetime="2025-08-05T11:02:36.000Z" title="发表于 2025-08-05 19:02:36">2025-08-05</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/05/2025-08-05-%E8%BF%90%E5%8A%A8%E5%AF%B9%E8%B1%A1%E5%88%86%E5%89%B2%E4%B8%8E%E9%85%8D%E5%87%86%E7%AE%97%E6%B3%95/" title="运动对象分割与配准算法">运动对象分割与配准算法</a><time datetime="2025-08-05T08:16:02.000Z" title="发表于 2025-08-05 16:16:02">2025-08-05</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/05/2025-08-05-%E6%9D%A1%E4%BB%B6%E6%AC%A7%E5%BC%8F%E8%81%9A%E7%B1%BB%E5%88%86%E5%89%B2/" title="条件欧式聚类分割">条件欧式聚类分割</a><time datetime="2025-08-05T07:56:39.000Z" title="发表于 2025-08-05 15:56:39">2025-08-05</time></div></div></div></div></div></div></main><footer id="footer"><div class="footer-other"><div class="footer-copyright"><span class="copyright">&copy;&nbsp;2025 By Fi9zero</span><span class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo 7.3.0</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly 5.4.2</a></span></div><div class="footer_custom_text">Only light can attract bugs.</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="日间和夜间模式切换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><div class="js-pjax"><script>(() => {
  const loadMathjax = () => {
    if (!window.MathJax) {
      window.MathJax = {
        tex: {
          inlineMath: [['$', '$'], ['\\(', '\\)']],
          tags: 'none',
        },
        chtml: {
          scale: 1.1
        },
        options: {
          enableMenu: true,
          renderActions: {
            findScript: [10, doc => {
              for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
                const display = !!node.type.match(/; *mode=display/)
                const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display)
                const text = document.createTextNode('')
                node.parentNode.replaceChild(text, node)
                math.start = {node: text, delim: '', n: 0}
                math.end = {node: text, delim: '', n: 0}
                doc.math.push(math)
              }
            }, '']
          }
        }
      }

      const script = document.createElement('script')
      script.src = 'https://cdn.jsdelivr.net/npm/mathjax/es5/tex-mml-chtml.min.js'
      script.id = 'MathJax-script'
      script.async = true
      document.head.appendChild(script)
    } else {
      MathJax.startup.document.state(0)
      MathJax.texReset()
      MathJax.typesetPromise()
    }
  }

  btf.addGlobalFn('encrypt', loadMathjax, 'mathjax')
  window.pjax ? loadMathjax() : window.addEventListener('load', loadMathjax)
})()</script><script>(() => {
  const runMermaid = ele => {
    window.loadMermaid = true
    const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'default'

    ele.forEach((item, index) => {
      const mermaidSrc = item.firstElementChild
      const mermaidThemeConfig = `%%{init:{ 'theme':'${theme}'}}%%\n`
      const mermaidID = `mermaid-${index}`
      const mermaidDefinition = mermaidThemeConfig + mermaidSrc.textContent

      const renderFn = mermaid.render(mermaidID, mermaidDefinition)
      const renderMermaid = svg => {
        mermaidSrc.insertAdjacentHTML('afterend', svg)
      }

      // mermaid v9 and v10 compatibility
      typeof renderFn === 'string' ? renderMermaid(renderFn) : renderFn.then(({ svg }) => renderMermaid(svg))
    })
  }

  const codeToMermaid = () => {
    const codeMermaidEle = document.querySelectorAll('pre > code.mermaid')
    if (codeMermaidEle.length === 0) return

    codeMermaidEle.forEach(ele => {
      const preEle = document.createElement('pre')
      preEle.className = 'mermaid-src'
      preEle.hidden = true
      preEle.textContent = ele.textContent
      const newEle = document.createElement('div')
      newEle.className = 'mermaid-wrap'
      newEle.appendChild(preEle)
      ele.parentNode.replaceWith(newEle)
    })
  }

  const loadMermaid = () => {
    if (true) codeToMermaid()
    const $mermaid = document.querySelectorAll('#article-container .mermaid-wrap')
    if ($mermaid.length === 0) return

    const runMermaidFn = () => runMermaid($mermaid)
    btf.addGlobalFn('themeChange', runMermaidFn, 'mermaid')
    window.loadMermaid ? runMermaidFn() : btf.getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(runMermaidFn)
  }

  btf.addGlobalFn('encrypt', loadMermaid, 'mermaid')
  window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid)
})()</script></div><script defer src="https://npm.elemecdn.com/jquery@latest/dist/jquery.min.js"></script><script defer data-pjax src="/js/pig.js"></script><script src="/js/weather.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="text-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="站内搜索..." type="text"/></div></div><hr/><div id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></div></body></html>